<template>
  <el-table :data="tableData" style="width: 100%">

    <el-table-column prop="name" label="任务名"></el-table-column>

    <!--<el-table-column prop="applyDocUrl" label="公司详细文档"></el-table-column>-->
    <el-table-column label="工作室详细文档">
      <template slot-scope="scope">
        <a  :href=scope.row.doc>点击下载代码及文档</a>
      </template>
    </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          size="mini"
          @click="handleEdit(scope.$index, scope.row)">同意</el-button>
        <el-button
          size="mini"
          type="danger"
          @click="handleDelete(scope.$index, scope.row)">拒绝</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
  export default {
    data() {
      return {
        tableData: [
          {
            id:'',
            name:'',
            doc:'',

          }
        ]
      }
    },
    mounted: function(){
      // var user= JSON.parse(window.sessionStorage.getItem("user"));
      // let r=user.id

      this.oid= this.$route.query.mallCode

      axios.post('/workroom/selectWorkroomProgress',{
        tdid:this.oid,
        id:this.oid
      }).then((response) => {

        if(response.data!==null){
          let ee=response.data
          console.log(ee)
          var data=[];
          let ff=0
          for(var c=0;c<ee.length;c++){
            var eee=ee[c]
            console.log(eee)
            if(eee.states==1){
              var obj={}
              obj.id=eee.id
              obj.name=eee.name
              obj.doc=eee.doc
              data[ff]=obj
              ff=ff+1
            }

          }
          this.tableData=data
          console.log(this.options)
        }  else{

        }
      }).catch((response)=>{

      })

    },
    methods: {
      handleEdit(index, row) {
        console.log(row.id)
        var ff=row.id


        axios.post('/workroom/upWorkroomProgressStates',{
          id : ff,
          states  : 2
        }).then((response) => {
          if( response.data.states== 800){
            this.$notify({
              title: '成功',
              message: '成功',
              type: 'success',
              duration:2000

            });
            location.reload()
          } else{
            this.$notify({
              title: '失败',
              message: '错误',
              type: 'warning',
              duration:2000
            });
          }
        })


      },
      handleDelete(index, row) {
        console.log(index, row);
        var ff=row.id
        axios.post('/workroom/upWorkroomProgressStates',{
          id : ff,
          states  : 0
        }).then((response) => {
          if( response.data.states== 800){
            this.$notify({
              title: '成功',
              message: '成功',
              type: 'success',
              duration:2000
            });
            location.reload()
          }
          else{
            this.$notify({
              title: '失败',
              message: '错误',
              type: 'warning',
              duration:2000
            });
          }
        })


      }

    }

    }
</script>



<style scoped>

</style>
